/*     */ package com.qmsk.business.info.largeClient.controller;
/*     */ 
/*     */ import com.qmsk.business.info.largeClient.dao.LargeClientDao;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.sql.SQLException;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/largeClient"})
/*     */ public class LargeClientController
/*     */ {
/*  28 */   private static final Logger logger = Logger.getLogger(LargeClientController.class);
/*     */ 
/*     */   @Autowired
/*     */   private LargeClientDao dao;
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListAll(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Integer shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  54 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  56 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId(shopId, nPageIdx, 
/*  57 */         nPageSize);
/*  58 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  60 */       logger.error(e);
/*  61 */       ResponseUtils.setErrorMsgResponse(
/*  62 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*  80 */     String sGsonInData = RequestUtils.getString(request, "data");
/*     */     try
/*     */     {
/*  83 */       int nResult = this.dao.insertJsonOneRow(sGsonInData);
/*  84 */       DbConnection.commit();
/*  85 */       ResponseUtils.setSqlResultResponse(nResult, 
/*  86 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/*  87 */         response);
/*     */     } catch (Exception e) {
/*  89 */       DbConnection.rollback();
/*  90 */       logger.error(e);
/*  91 */       ResponseUtils.setErrorMsgResponse(
/*  92 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/*  93 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 105 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 107 */       String[] strParams = id.split(",");
/* 108 */       int nResult = this.dao.deleteParams(strParams);
/* 109 */       DbConnection.commit();
/* 110 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 111 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 112 */         response);
/*     */     } catch (Exception e) {
/* 114 */       DbConnection.rollback();
/* 115 */       logger.error(e);
/* 116 */       ResponseUtils.setErrorMsgResponse(
/* 117 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 118 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void update(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 135 */     String id = request.getParameter("id");
/*     */     try {
/* 137 */       GsonHeadOneRow g = GsonHeadOneRow.jsonStrToObject(RequestUtils.getString(request, "data"));
/* 138 */       if (g == null) {
/* 139 */         ResponseUtils.setErrorMsgResponse(
/* 140 */           RequestUtils.getReadJsonDataErrorMessage(request), 
/* 141 */           response);
/* 142 */         return; }
/* 143 */       int nResult = this.dao.updateJsonOneRow(g, id);
/* 144 */       DbConnection.commit();
/* 145 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 146 */         RequestUtils.getSqlUpdateDataErrorMessage(request), 
/* 147 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 150 */       DbConnection.rollback();
/* 151 */       logger.error(e);
/* 152 */       ResponseUtils.setErrorMsgResponse(
/* 153 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/* 154 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.info.largeClient.controller.LargeClientController
 * JD-Core Version:    0.5.3
 */